package org.vestbjergbyggecenter.Model;

import java.util.ArrayList;

public class SalesAssistant extends Employee{
	public ArrayList<Order> ordersMade;
	public double norm;
	
	//Constructor
	public SalesAssistant(int salesID, String salesName, long salesCPR, String salesAddress, long salesPostalCode, String salesCity, String salesPhone, String salesUsername, String salesPassword, int salesSalary)
	{
		super(salesID, salesName, salesCPR, salesAddress, salesPostalCode, salesCity, salesPhone, salesUsername, salesPassword, salesSalary);
		this.norm=2.5;
		ordersMade=new ArrayList<Order>();
	}
	
	/*
	 * Method sets the id of a sales assistant.
	 */
	
	 public void setSalesAssistantID(int newSalesAssistantID)	
	{
		super.setEmployeeID(newSalesAssistantID);
	}
	
	
	/*
	 * Method returns the id of a sales assistant.
	 */
	public int getSalesAssistanID()
	{
		return super.getEmployeeID();
	}
	
	/*
	 * Method sets the username of a sales assistant.
	 */
	public void setSalesAssistantUsername(String newSalesAssistantUsername)
	{
		super.setUsername(newSalesAssistantUsername);
	}

	/*
	 * Method returns the username of a sales assistant.
	 */
	public String getSalesAssistantUsername()
	{
		return super.getUsername();
	}
	
	/*
	 * Method sets the password for a sales assistant.
	 */
	public void setSalesAssistantPassword(String newSalesAssistantPassword)
	{
		super.setPassword(newSalesAssistantPassword);
	}
	
	/*
	 * Method returns the password of a sales assistant.
	 */
	public String getSalesAssistantPassword()
	{
		return super.getPassword();
	}
	
	/*
	 * Method sets the salary of a sales assistant.
	 */
	public void setSalesAssistatSalary(int newSalesAssistantSalary)
	{
		super.setSalary(newSalesAssistantSalary);
	}
	
	/*
	 * Method returns the salary of a sales assistant.
	 */
	public int getSalesAssistantSalary()
	{
		return super.getSalary();
	}
	
	//Method adds an order to the orders made by a sales assistant.
	public void addMadeOrder(Order order)
	{
		ordersMade.add(order);
	}
	
	//Method returns the made orders on the sales assistant
	public ArrayList<Order> getMadeOrder()
	{
		return ordersMade;
	}
	
	/*
	 * Method gives the norm of a sales assistant.
	 * ID based
	 */
	public double calculateNorm(int selectedID)
	{		
		if(getSalesAssistanID()==selectedID)
		{
			for(Order order: ordersMade)
			{
				if(order.getSalesAssistant().getSalesAssistanID()==selectedID)
				{
					norm=norm - order.getTotalPrice();
				}				
			}			
		}
		else
		{
			System.out.println("Please insert the correct sales assistan ID.");
		}
		return norm;		
	}
	
	//Method to print orders done by a particular sales assistant
	//ID based.
	public void printSalesOrders()
	{
		System.out.println("The sales assistant with the ID " + getSalesAssistanID() + " has made the following orders:");
		for(Order order :OrderRecords.getInstance().getOrders())
		{
		if(order.getSalesAssistant().getSalesAssistanID()==getSalesAssistanID())
			{
				System.out.println();
				order.printShort();
			}
		}
	}
}
